package com.chen.serviceprice.controller;

import com.chen.internalcommon.dto.ResponseResult;
import com.chen.internalcommon.request.ForecastPriceRequest;
import com.chen.serviceprice.service.ForecastPriceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenLiuPing
 **/
@RestController
@Slf4j
public class ForecastPriceController {


    @Autowired
    private ForecastPriceService forecastPriceService;

    /**
     * 计算预估价格
     * @param forecastPriceRequest
     * @return
     */
    @PostMapping("/forecast-price")
    public ResponseResult forecastPrice(@RequestBody ForecastPriceRequest forecastPriceRequest) {
        String depLongitude = forecastPriceRequest.getDepLongitude();
        String depLatitude = forecastPriceRequest.getDepLatitude();
        String destLongitude = forecastPriceRequest.getDestLongitude();
        String destLatitude = forecastPriceRequest.getDestLatitude();
        String cityCode = forecastPriceRequest.getCityCode();
        String vehicleType = forecastPriceRequest.getVehicleType();
        return forecastPriceService.forecastPrice(depLongitude, depLatitude,
                destLongitude, destLatitude,
                cityCode, vehicleType);
    }
}
